import React from "react";
import style from "./index.module.scss";
import header from "../../base/Header/index";

class PrivateInfo extends React.Component {

    state = {
        userinfo:{uid:""}
    }

    logout(){
        let temp = localStorage.getItem("userList");
        if(temp){
            localStorage.removeItem("userList");
            localStorage.setItem("userList_temp",temp);
        }
        this.props.history.replace("/login");
    }


    componentDidMount(){
        let temp = localStorage.getItem("userList");
        if(!temp) return this.props.history.push("/login");
        this.setState({userinfo:JSON.parse(temp)});
    }

    render(){
        let {userinfo} = this.state;
        return (
            <div className={style["index-root"]}>
                {header({title:"账户安全",history:this.props.history})}
                <img className={style["user-head"]} src={"/apis/"+userinfo.head_url} />
                <button className={style["logout-btn"]} onClick={this.logout.bind(this)}>注销</button>
                <div>
                    <p>改密码</p>
                    <p>改手机号</p>
                    <p>改昵称</p>
                    <p>申诉-修改认证信息</p>
                </div>
            </div>
        )
    }
}

export default PrivateInfo;
